Return a new reference to an existing GdkWindow if one already exists.
authorMatthias Clasen <mclasen@redhat.com>
Tue, 5 Oct 2004 05:40:42 +0000 (05:40 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 5 Oct 2004 05:40:42 +0000 (05:40 +0000)
2004-10-05  Matthias Clasen  <mclasen@redhat.com>

* gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display):
Return a new reference to an existing GdkWindow if one already
exists.  (#151378, Gustavo Carneiro)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/x11/gdkwindow-x11.c

index 459fbc2ac918837e9a260bc178720c12a0488ddc..1dfdc901b3c6d1abb13125fc8dba3e9b4adf5e49 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-10-05  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): 
+       Return a new reference to an existing GdkWindow if one already
+       exists.  (#151378, Gustavo Carneiro)
+
 2004-10-05  Matthias Clasen  <mclasen@redhat.com>
 
        Provide access to the string representation of accelerators used
index 459fbc2ac918837e9a260bc178720c12a0488ddc..1dfdc901b3c6d1abb13125fc8dba3e9b4adf5e49 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-05  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): 
+       Return a new reference to an existing GdkWindow if one already
+       exists.  (#151378, Gustavo Carneiro)
+
 2004-10-05  Matthias Clasen  <mclasen@redhat.com>
 
        Provide access to the string representation of accelerators used
index 459fbc2ac918837e9a260bc178720c12a0488ddc..1dfdc901b3c6d1abb13125fc8dba3e9b4adf5e49 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-05  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): 
+       Return a new reference to an existing GdkWindow if one already
+       exists.  (#151378, Gustavo Carneiro)
+
 2004-10-05  Matthias Clasen  <mclasen@redhat.com>
 
        Provide access to the string representation of accelerators used
index 459fbc2ac918837e9a260bc178720c12a0488ddc..1dfdc901b3c6d1abb13125fc8dba3e9b4adf5e49 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-05  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkwindow-x11.c (gdk_window_foreign_new_for_display): 
+       Return a new reference to an existing GdkWindow if one already
+       exists.  (#151378, Gustavo Carneiro)
+
 2004-10-05  Matthias Clasen  <mclasen@redhat.com>
 
        Provide access to the string representation of accelerators used
index 6a281d88e9be8aeae780f792d6d8d7e9a951a8cf..123073917c112bf795f5361a5b43bbf148ab4a77 100644 (file)
@@ -947,13 +947,16 @@ x_event_mask_to_gdk_event_mask (long mask)
  * @anid: a native window handle.
  * 
  * Wraps a native window in a #GdkWindow.
- * This may fail if the window has been destroyed.
+ * This may fail if the window has been destroyed. If the window
+ * was already known to GDK, a new reference to the existing 
+ * #GdkWindow is returned.
  *
  * For example in the X backend, a native window handle is an Xlib
  * <type>XID</type>.
  * 
- * Return value: the newly-created #GdkWindow wrapper for the 
- *    native window or %NULL if the window has been destroyed.
+ * Return value: a #GdkWindow wrapper for the native window or 
+ *   %NULL if the window has been destroyed. The wrapper will be
+ *   newly created, if one doesn't exist already.
  *
  * Since: 2.2
  **/
@@ -975,7 +978,10 @@ gdk_window_foreign_new_for_display (GdkDisplay     *display,
   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
 
   display_x11 = GDK_DISPLAY_X11 (display);
-  
+
+  if ((window = gdk_xid_table_lookup_for_display (display, anid)) != NULL)
+    return g_object_ref (window);
+
   gdk_error_trap_push ();
   result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs);
   if (gdk_error_trap_pop () || !result)